<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>OA 助手测试</title>
    <script src="./base64.js"></script>
    <script src="jquery.min.js"></script>
    <script src="./checkwps.js"></script>
    <script src="launchwps.js"></script>
    <script src="wps.js"></script>
    <script>

        var strBookmarkDataPath = "http://dev.wpseco.cn/bookmark/getAllBookmark";
        var templatePath = "http://dev.wpseco.cn/template/paging";
        var docId = "7b89e10e106d96c1de6ed46a4a22e7847d5423af";
        var uploadPath = "http://dev.wpseco.cn/file/upload?id=" + docId;
        var fileName = "http://dev.wpseco.cn/file/download/" + docId
        function newDoc(){
            _wps.newDoc({
                "uploadPath": "http://dev.wpseco.cn/file/uploadFromWps", //保存文档接口
                "strBookmarkDataPath": strBookmarkDataPath,//书签列表接口
                "templatePath": templatePath,//正文模板列表接口
                "buttonGroups": "btnSaveAsFile,btnImportDoc,btnPageSetup,btnInsertDate,btnSelectBookmark,btnImportTemplate"
            })
        }

        function openDoc(){
            _wps.openDoc({
                "docId":docId,
                "uploadPath":uploadPath,
                "fileName":fileName,
                "strBookmarkDataPath": strBookmarkDataPath,//书签列表接口
                "templatePath": templatePath,//公文模板列表接口
                "buttonGroups": "btnSaveAsFile,btnImportDoc,btnPageSetup,btnInsertDate,btnSelectBookmark,btnImportTemplate",
                "userName": '王五'//用户名
            });
        }

        function protectOpen(){
            _wps.openDoc({
                "docId": docId, //文档ID
                "uploadPath": "http://dev.wpseco.cn/file/place?id=" + docId + "&type=1", //保存文档接口
                "fileName": fileName, //根据文档id获取服务器文档接口
                "buttonGroups": "btnChangeToPDF,btnChangeToUOT,btnChangeToUOF",
                "openType": { //文档打开方式
                    //文档保护类型，-1：不启用保护模式，0：只允许对现有内容进行修订，1：只允许添加批注，2：只允许修改窗体域，3：只读
                    "protectType": 3,
                    "password": "123456"
                }
            });
        }

        function revisionCtrlOpen(){
            _wps.openDoc({
                "docId": docId, //文档ID
                "uploadPath": uploadPath, //保存文档接口
                "fileName": fileName, //根据文档id获取服务器文档接口
                "buttonGroups": "btnOpenRevision,btnShowRevision,btnAcceptAllRevisions,btnRejectAllRevisions",
                "userName": 'wangyifei',//用户名
                "revisionCtrl":{
                    "bOpenRevision":true,
                    "bShowRevision":true
                }
            });
        }
        function onlineEdit(){
            _wps.onlineEditDoc({
                "docId": docId, //文档ID
                "uploadPath": uploadPath, //保存文档接口
                "fileName": fileName, //根据文档id获取服务器文档接口
                "strBookmarkDataPath": strBookmarkDataPath,//书签列表接口
                "templatePath": templatePath,//正文模板列表接口
                "buttonGroups": "btnSaveAsFile,btnImportDoc,btnPageSetup,btnInsertDate,btnSelectBookmark,btnImportTemplate",
                "userName": '王五'//用户名
            })
        }

        function fillRedhead(){
            _wps.insertRedHeadDocFromWeb({
                "docId": docId, //文档ID
                "uploadPath": uploadPath, //保存文档接口
                "fileName": fileName, //根据文档id获取服务器文档接口
                "buttonGroups": "btnInsertRedHeader",
            }, "http://dev.wpseco.cn/file/download/b528ce0b140d46879c9c8576ffbc3e98", "Content");//红头模板中填充正文的位置书签名
        }
        function fillTemplate(){
            _wps.fillTemplate({
                "docId": docId, //文档ID
                "templateURL": "http://dev.wpseco.cn/wps-oa/template/getFileData/98", //访问服务器模板接口
                "dataFromWeb": [{"name": "FirstTitle", "text": "web"}, {
                    "name": "TopTitle1",
                    "text": "军参谋-web"
                }, {"name": "TopTitle2", "text": "通信-web"}, {
                    "name": "ContentTitle",
                    "text": "空军内部使用办文助手-web"
                }, {"name": "Company", "text": "空军参谋部-web"}, {
                    "name": "Contactor",
                    "text": "李四-web"
                }, {"name": "Telephone", "text": "26874"}, {
                    "name": "Content",
                    "text": fileName,
                    "type": "link"
                }], //后台获取数据的接口,
                "uploadPath": uploadPath, //保存文档接口
                // "dataFromServer": "http://dev.wpseco.cn/wps-oa/document/getData"
            });
        }
    </script>
</head>
<body>
    <p>文档相关</p>
    <button id="openDoc" onclick="newDoc()">新建doc</button>
    <button id="openDoc" onclick="openDoc()">打开指定doc</button>
    <button id="openDoc" onclick="protectOpen()">保护模式打开</button>
    <button id="openDoc" onclick="revisionCtrlOpen()">修订模式打开</button>
    <button id="openDoc" onclick="onlineEdit()">文档不落地</button>
    <button id="fillRedhead" onclick="fillRedhead()">套红头</button>
    <button id="openET" onclick="fillTemplate()">填充模板</button><br/>
    <p>表格</p>
    <button id="openDoc">启动et</button>
    <!-- <button id="openDoc">启动doc</button> -->
</body>
<script>
    document.getElementById("openDoc")
</script>
</html>
